package com.itheima.service.impl;

import com.itheima.mapper.BookShelfMapper;
import com.itheima.pojo.Book;
import com.itheima.pojo.Bookshelf;
import com.itheima.service.BookShelfService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class BookShelfServiceImpl implements BookShelfService {
    @Autowired
    private BookShelfMapper bookShelfMapper;
    @Override
    public List<Bookshelf> list() {
        List<Bookshelf> bookshelfList = bookShelfMapper.list();
        return bookshelfList;
    }

    @Override
    public void addBookShelf(Bookshelf bookshelf) {
        bookshelf.setUpdateTime(LocalDateTime.now());
        bookshelf.setCreateTime(LocalDateTime.now());
        bookShelfMapper.add(bookshelf);
    }

    @Override
    public void updateBookShelf(Bookshelf bookshelf) {
        bookshelf.setUpdateTime(LocalDateTime.now());
        bookShelfMapper.updateShelf(bookshelf);
    }

    @Override
    public void deleteBookShelf(Integer id) {
        bookShelfMapper.deleteShelf(id);
    }
}
